package cn.itcast.service.mobileImpl;

import cn.itcast.constant.MessageConstant;
import cn.itcast.dao.AddressDao;
import cn.itcast.entity.Result;
import cn.itcast.mobile.MoblieAddressService;
import cn.itcast.pojo.Address;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.stream.Collectors;

/**
 * Demo class
 *
 * @author gyc
 * @date 2021/10/17
 */
@Service
public class MobileAddressServiceImpl implements MoblieAddressService {

    @Autowired
    private AddressDao addressDao;

    @Override
    public Result findAll() {
        List<Address> list = addressDao.findAll();
        List<Integer> addressId = list.stream().map(address -> address.getId()).collect(Collectors.toList());
        if (list == null) {
            return new Result(false, MessageConstant.QUERY_ADDRESS_FAIL);
        }
        return new Result(true, MessageConstant.QUERY_ADDRESS_SUCCESS,list);
    }
}
